package com.ruoyi.web.controller.tool;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.mail.SendMailUtil;
import com.ruoyi.common.utils.mail.domain.MailContent;
import com.ruoyi.framework.manager.AsyncManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: MMDZ
 * @Desc: TODO 邮件
 */
@RestController
@RequestMapping("/tool/mail")
public class MailController {

    @Autowired
    private SendMailUtil sendMailUtil;

    @PreAuthorize("@ss.hasPermi('tool:mail:send')")
    @PostMapping("/send")
    public AjaxResult send(@Validated @RequestBody MailContent mailContent) {
        AsyncManager.me().execute(sendMailUtil.sendSimpleMail(mailContent));
        return AjaxResult.success();
    }

}
